//
//  UIImage+Extension.swift
//  CLWeibo
//
//  Created by 陈亮 on 16/7/17.
//  Copyright © 2016年 陈亮. All rights reserved.
//

import UIKit
//处理截图屏幕快照
extension UIImage {
    
    class  func getScreenShot () -> UIImage {
        //获取主窗口
        let window = UIApplication.sharedApplication().keyWindow!
        //开启图片上下文
        UIGraphicsBeginImageContext(window.size)
        //把window内容渲染到图片上下文中,性能比drawRect要高
        window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: false )
        //从上下文中获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        //关闭上下文
        UIGraphicsEndImageContext()
        return image
}
}